﻿<%@ Page Title="" Language="C#" MasterPageFile="../../Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">

    <h2>TestJson</h2>
    <script type="text/javascript" src="<%= Url.EzDeskUrl("Project", "/Scripts/gserializer.js", null) %>"></script>
    <script type="text/javascript" src="<%= Url.EzDeskUrl("Project", "/Scripts/dhtmlxgantt.js", null) %>"></script>
    <script type="text/javascript" src="<%= Url.EzDeskUrl("Project", "/Scripts/dhtmlxgantt.ext.js", null) %>"></script>

    <link href="<%= Url.EzDeskUrl("Project", "/Content/dhtmlxgantt.css", null) %>" rel="stylesheet" type="text/css" />
    
    
    
    <script type="text/javascript">
        //Generate test data
        function GetDataFromServer() {
            var dataFromServer =
            {

                Name: "XXXX项目",
                Description: "XXXXXXXXXXXXXXX",
                Planes:
            [{
                Id: "1",
                Name: "青山老妖在等待",
                Director: { Name: "青山老妖", Id: "123" },
                StartOn: new Date(2010, 4, 2),
                TeamMembers: [
                    { Name: "青山老妖", Id: "123" },
                    { Name: "左右为难", Id: "456" }
                ],
                ChildTasks:
                [
                    {
                        Id: "1",
                        Name: "青1",
                        Director: { Name: "青山老妖", Id: "123" },
                        StartOn: new Date(2010, 4, 2),
                        Duration: 144,
                        IsCompleted: false,
                        DependencyTaskId: "",
                        ChildTasks:
                        [
                            {
                                Id: "2",
                                Name: "青1-1",
                                Director: { Name: "青山老妖", Id: "123" },
                                StartOn: new Date(2010, 4, 2),
                                Duration: 100,
                                IsCompleted: true,
                                DependencyTaskId: "",
                                ChildTasks: []
                            },
                            {
                                Id: "3",
                                Name: "青1-2",
                                Director: { Name: "青山老妖", Id: "123" },
                                StartOn: new Date(2010, 4, 2),
                                Duration: 120,
                                IsCompleted: false,
                                DependencyTaskId: "",
                                ChildTasks: []
                            }
                        ]
                    }
                ]
            },
            {
                Id: "1",
                Name: "青山老妖在等待",
                Director: { Name: "青山老妖", Id: "123" },
                StartOn: new Date(2010, 4, 2),
                TeamMembers: [
                    { Name: "青山老妖", Id: "123" },
                    { Name: "左右为难", Id: "456" }
                ],
                ChildTasks:
                [
                    {
                        Id: "1",
                        Name: "青1",
                        Director: { Name: "青山老妖", Id: "123" },
                        StartOn: new Date(2010, 4, 2),
                        Duration: 144,
                        IsCompleted: false,
                        DependencyTaskId: "",
                        ChildTasks:
                        [
                            {
                                Id: "2",
                                Name: "青1-1",
                                Director: { Name: "青山老妖", Id: "123" },
                                StartOn: new Date(2010, 4, 2),
                                Duration: 100,
                                IsCompleted: true,
                                DependencyTaskId: "",
                                ChildTasks: []
                            },
                            {
                                Id: "3",
                                Name: "青1-2",
                                Director: { Name: "青山老妖", Id: "123" },
                                StartOn: new Date(2010, 4, 2),
                                Duration: 120,
                                IsCompleted: false,
                                DependencyTaskId: "",
                                ChildTasks: []
                            }
                        ]
                    }
                ]
            }]
            };
            return dataFromServer;
        }

        var ganttChartControl = new GanttChart();
        $(function () {
            var serverData = GetDataFromServer();
            ganttChartControl.loadDataIn('GanttDiv', serverData);
            //            $("#ComboxBinding").comboxBinding(serverData.TeamMembers, "Name", "Id");
        }
        );
        var displayDialog = $('<div/>');
        function SaveToServer() {
            //do something
            var dataToServer = ganttChartControl.getServerData();
            var serializer = new ONEGEEK.GSerializer();
            var seriValue = serializer.serialize(dataToServer, "Plane", "");
            displayDialog.attr("innerHTML", seriValue).dialog();

        }
    </script>
    Simple read-only chart:
    <button value="Save" onclick="SaveToServer();">
        Save
    </button>
    <select id="ComboxBinding"></select>
    <div style="width: 950px; height: 600px; position: relative" id="GanttDiv">
    </div>
</asp:Content>
